package wyn.spec.edu.week12_class01;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

    public class ThirdAdapter extends RecyclerView.Adapter<ThirdAdapter.ViewHolder> {
        private List<Third> mThirdList;
        static class ViewHolder extends RecyclerView.ViewHolder{
            ImageView image;
            TextView name;
            public ViewHolder(View view){
                super(view);
                image=(ImageView) view.findViewById(R.id.third_image);
                name=(TextView) view.findViewById(R.id.name);

            }
        }
        public ThirdAdapter(List<Third> thirdlyList){
            mThirdList=thirdlyList;
        }
        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int i) {
            View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.third_item,parent,false);
            ViewHolder holder=new ViewHolder(view);
            return holder;
        }

        @Override
        public void onBindViewHolder(ViewHolder holder, int position) {
            Third third=mThirdList.get(position);
            holder.image.setImageResource(third.getImage());
            holder.name.setText(third.getName());
        }

        @Override
        public int getItemCount() {
            return mThirdList.size();
        }
    }

